//
//  segmentVC.m
//  Notification
//
//  Created by Apple on 2017/3/22.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "segmentVC.h"
#import "HongFile.pch"
@interface segmentVC ()

@end

@implementation segmentVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"SegmentVC";
    self.view.backgroundColor = [UIColor whiteColor];
    NSArray*segArray = [NSArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    self.seg = [[UISegmentedControl alloc]initWithItems:segArray];
    self.seg.frame = CGRectMake(50, 100, SCREEN_WIDTH-100, 50);
#pragma mark-设置默认index
    self.seg.selectedSegmentIndex = 2;
//#pragma mark-设置切圆觉
//    self.seg.layer.cornerRadius = 20;
//    self.seg.clipsToBounds = YES;
    self.seg.tintColor = [UIColor grayColor];
    [self.view addSubview:self.seg];
    [self.seg addTarget:self action:@selector(changePicture) forControlEvents:UIControlEventValueChanged];
    
    self.img = [[UIImageView alloc]initWithFrame:CGRectMake(50, 180, SCREEN_WIDTH-100, 350)];
    self.img.image = [UIImage imageNamed:@"picture2.jpg"];
    [self.view addSubview:self.img];
}
#pragma mark-动态改变图片
-(void)changePicture{
    self.img.image = [UIImage imageNamed:[NSString stringWithFormat:@"picture%ld.jpg",self.seg.selectedSegmentIndex]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
